<template>
  <div class="icons">
    <div class="icon" v-for="item of iconUrlList" :key="item.id">
      <div class="icon-img">
        <img class="icon-img-item" :src="item.imgUrl"/>
      </div>
      <p class="icon-text">{{item.title}}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'HomeIcons',
  data () {
    return {
      iconUrlList: [
        {
          id: '01',
          title: '景点门票',
          imgUrl: require('images/icons/icon1.png')
        },
        {
          id: '02',
          title: '一日游',
          imgUrl: require('images/icons/icon2.png')
        },
        {
          id: '03',
          title: '上海迪士尼',
          imgUrl: require('images/icons/icon3.png')
        },
        {
          id: '04',
          title: '上海海昌',
          imgUrl: require('images/icons/icon4.png')
        },
        {
          id: '05',
          title: '野生动物园',
          imgUrl: require('images/icons/icon5.png')
        },
        {
          id: '06',
          title: '上海欢乐谷',
          imgUrl: require('images/icons/icon6.png')
        },
        {
          id: '07',
          title: '上影乐园',
          imgUrl: require('images/icons/icon7.png')
        },
        {
          id: '08',
          title: '东方明珠东方明珠东方明珠',
          imgUrl: require('images/icons/icon8.png')
        },
        {
          id: '09',
          title: '景点门票',
          imgUrl: require('images/icons/icon1.png')
        }
      ]
    }
  }
}
</script>

<style lang="stylus" scoped>
  @import '~styles/varibles.styl'
  .icons
    overflow: hidden
    height: 0
    padding-bottom: 50% /*1.表示高度是 自身的 宽度的一半*/
    .icon
      position: relative
      overflow: hidden
      float: left
      width: 25% /*2.表示宽度是 父容器 宽度的25%, 也就是父容器 高度的一半 */
      height: 0
      padding-bottom: 25%
      .icon-img
        position: absolute
        top: 0
        left: 0
        right: 0
        bottom: .44rem
        box-sizing: border-box
        padding: .05rem
        .icon-img-item
          display: block
          margin: 0 auto
          height: 100%
      .icon-text
        position: absolute
        left: 0
        right: 0
        bottom: 0
        height: .44rem
        line-height: .44rem
        text-align: center
        color: $darkTextColor
</style>
